package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.dubbo.mappers.ReportMapper;
import com.tanhua.model.db.Report;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class ReportApiImpl implements ReportApi{
    @Autowired
    private ReportMapper reportMapper;

    @Override
    public List<Report> findByUserId(Long userId) {
        QueryWrapper qw = new QueryWrapper();
        qw.eq("user_id",userId);
        List<Report> list = reportMapper.selectList(qw);
        return list;
    }

    @Override
    public Integer save(Report report) {
        reportMapper.insert(report);
        return report.getReportId();
    }

    @Override
    public Report findById(Integer id) {
        QueryWrapper qw = new QueryWrapper();
        qw.eq("report_id",id);
        return reportMapper.selectOne(qw);
    }

    @Override
    public List<Report> findAll() {
        return reportMapper.selectList(null);
    }
}
